package com.jdkreader.concurrency.concurrent.pipeline;

import java.util.concurrent.TimeUnit;

/**
 * 汽车底盘创建类
 */
public class ChassisBuilder implements Runnable{

    private  int counter=0;
    private CarQueue carQueue;

    public ChassisBuilder(CarQueue cq) {
        carQueue=cq;
    }

    public void run(){
        try{
            while(!Thread.interrupted()){
                TimeUnit.MILLISECONDS.sleep(500);
                Car car=new Car(counter++);
                System.out.println("ChassisBuilder created " + car);
                carQueue.put(car);
            }
        }catch(InterruptedException e){
            e.printStackTrace();
        }
        System.out.println(" ChassisBuilder off ");
    }

}
